# Contributor: Alisa <corg@disroot.org>
# Contributor: Maxim Karasev <begs@disroot.org>
# Maintainer: Alisa <corg@disroot.org>
pkgname=gamescope
pkgver=3.14.23
pkgrel=0
_libliftoff=8b08dc1c14fd019cc90ddabe34ad16596b0691f4
_openvr=ebd425331229365dc3ec42d1bb8b2cc3c2332f81
_reshade=696b14cd6006ae9ca174e6164450619ace043283
# requires stb_image_resize.h from older stb
_stb=5736b15f7ea0ffb08dd38af21067c314d6a3aae9
_vkroots=5106d8a0df95de66cc58dc1ea37e69c99afc9540
_wlroots=a5c9826e6d7d8b504b07d1c02425e6f62b020791
pkgdesc="SteamOS session compositing window manager"
url="https://github.com/ValveSoftware/gamescope"
arch="all"
license="BSD-2-Clause"
makedepends="
	benchmark-dev
	cmake
	glm-dev
	glslang-dev
	hwdata-dev
	libavif-dev
	libcap-dev
	libdecor-dev
	libdisplay-info-dev
	libei-dev
	libinput-dev
	libseat-dev
	libx11-dev
	libxcomposite-dev
	libxcursor-dev
	libxdamage-dev
	libxkbcommon-dev
	libxmu-dev
	libxrender-dev
	libxres-dev
	libxtst-dev
	libxxf86vm-dev
	meson
	pipewire-dev
	pixman-dev
	sdl2-dev
	spirv-headers
	stb
	vulkan-loader-dev
	wayland-protocols
	xcb-util-errors-dev
	xcb-util-wm-dev
	xwayland-dev
	"
source="https://github.com/Plagman/gamescope/archive/refs/tags/$pkgver/gamescope-$pkgver.tar.gz
	libliftoff-$_libliftoff.tar.gz::https://gitlab.freedesktop.org/emersion/libliftoff/-/archive/$_libliftoff.tar.gz
	openvr-$_openvr.tar.gz::https://github.com/ValveSoftware/openvr/archive/$_openvr.tar.gz
	reshade-$_reshade.tar.gz::https://github.com/Joshua-Ashton/reshade/archive/$_reshade.tar.gz
	stb-$_stb.tar.gz::https://github.com/nothings/stb/archive/$_stb.tar.gz
	vkroots-$_vkroots.tar.gz::https://github.com/Joshua-Ashton/vkroots/archive/$_vkroots.tar.gz
	wlroots-$_wlroots.tar.gz::https://github.com/Joshua-Ashton/wlroots/archive/$_wlroots.tar.gz
	limits.patch
	rt.patch
	steamcompmgr-deadlock.patch
	system-spirv-headers.patch
	unistd.patch
	wlnull.patch
	"
options="!check" # no tests

prepare() {
	default_prepare

	rmdir subprojects/libliftoff
	rmdir subprojects/openvr
	rmdir src/reshade
	rmdir subprojects/vkroots
	rmdir subprojects/wlroots

	ln -sfv "$srcdir"/libliftoff-$_libliftoff subprojects/libliftoff
	ln -sfv "$srcdir"/openvr-$_openvr subprojects/openvr
	ln -sfv "$srcdir"/reshade-$_reshade src/reshade
	ln -sfv "$srcdir"/vkroots-$_vkroots subprojects/vkroots
	ln -sfv "$srcdir"/wlroots-$_wlroots subprojects/wlroots

	cp "$srcdir"/stb-$_stb/stb_image_resize.h src/
}

build() {
	CXXFLAGS="$CXXFLAGS -DRTLD_DEEPBIND=0" \
	abuild-meson \
		-Ddefault_library=static \
		-Davif_screenshots=enabled \
		-Ddrm_backend=enabled \
		-Dinput_emulation=enabled \
		-Dpipewire=enabled \
		-Drt_cap=enabled \
		-Dsdl2_backend=enabled \
		. output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install \
		--no-rebuild \
		--skip-subprojects \
		-C output
}
sha512sums="
82ed94cc0321f4b8f06fca40c8d364f187f3482e045f3bfc74bab22ae1c1ca85fed8d3ec1748ac1a85c552f854585794ea6729e26737e81051b7b965101b79db  gamescope-3.14.23.tar.gz
9547f26523a90c7ccb92881579f59cf59b1dff1a1c482ba3eabe5ef5b2f0f03e2c804dbd64e98437c23c44713f544c823bbe4d29667f780d706d123b5dc0e3ae  libliftoff-8b08dc1c14fd019cc90ddabe34ad16596b0691f4.tar.gz
2edb54fd1f761fd3ac662ce26ed539af36abf1caab340a2a637c3bf017ca4df38fc9577bc7c1e8bd59039a92d44789cdfd1cd7566ffc0bbf9d1d38ebdc9b2552  openvr-ebd425331229365dc3ec42d1bb8b2cc3c2332f81.tar.gz
7fe1fe07622efd90bd94e1755019ca47657acd07137669e00b97bf70017a58c1f699e3dec1c720caafd1296275c7a25fd2f4d6e478cebbdf48bd69f985a00cdf  reshade-696b14cd6006ae9ca174e6164450619ace043283.tar.gz
55bc75284cf8a092c527d1ae18c461c9d0ab6aacdcf3b873abde54c06d9b8a0ae249ce47c7ad25809e075bfbb58e9c879d43e1df2708083860c07ac3bbb30d60  stb-5736b15f7ea0ffb08dd38af21067c314d6a3aae9.tar.gz
726e65dd0bb322d537e985ba2e504c68ef1b474574f11a5b102edcb8a7b74a6d86dea132c3b11417399a00beff9163e7aad413a389cf6073ec44d5ce6175ffc5  vkroots-5106d8a0df95de66cc58dc1ea37e69c99afc9540.tar.gz
6857ded750fda91d55e53edfc270eb4e7bf44d7330d17c8fcd13c248c71abba685f34260d1e6d20cdb302a8d4f9158fb43421943cca74630fd780a4048aed07b  wlroots-a5c9826e6d7d8b504b07d1c02425e6f62b020791.tar.gz
7969504c2ca35790c9758cf5d1a042a625ec92ad4dbc00afa65fc688b8f12d989047859f0bfb36883e7d82e1ade85a67ca998b5a19ea1b9230a814ca6bce0e0c  limits.patch
9c96bd654f8bbd30c2657dd98c098c2c8b388715ac8fa60d187fa5d134880a7f6a6f58b602c78a8716b97ce3344615e42136bd8d1220d82e9c9751cf77a4f7f5  rt.patch
fc84d35c818c307431c4fcfcfc8feb07cd70c0ed564ea02a0356f414533949cb6b2718e5ecdcf073a1efe1e34d9c7a712130da9329337afdb4a8bbbbdf3cd41b  steamcompmgr-deadlock.patch
b9ff1a1208941f62ee8a2f328b37afa9ae0fcacfa3e962a4c789f23f9eaf775b6f7a834664089ff596b899bc509613a3ddec24101d05d83c45f31f06a4388eb6  system-spirv-headers.patch
a5a27e7077d8c81b60477fcbc495f55a31c6a52e2bc8ec75663297f7c5169dbbcda1a2835425b543d97a3ee1208bc1187be3203540defc57b5be5fb31c8e6ef3  unistd.patch
181028d318d6290a7383ec7fd8a0911b29a573e8933dc88b1a29d6d4e74891a6234821c717745ee75acb89a4d40d37450c8fc653c3bb168658333ff0718985b8  wlnull.patch
"
